package app.component;

import java.awt.FlowLayout;

import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.JToolBar;

/**
 * @author Evstigneev Kirill (kester)
 */
public class StatusBar extends JToolBar {
	
	private int frames;
	private JProgressBar progressBar;
	private JLabel frameLabel;
	
	public StatusBar() {
		frames = 0;
	}
	
	public void addFrame() {
		frames++;
		updateFrameCount();
	}
	
	public void reset() {
		frames = 0;
		updateFrameCount();
	}

	private void updateFrameCount() {
		frameLabel.setText(String.valueOf(frames));
	}

	public void init() {
		setLayout(new FlowLayout(FlowLayout.RIGHT));
		setFloatable(false);
		
		progressBar = new JProgressBar();
		progressBar.setVisible(true);
		
		add(new JLabel("Frames captured:"));
		add(frameLabel = new JLabel(String.valueOf(frames)));
		add(new JLabel("Image processing:"));
		add(progressBar);
		
		setVisible(true);
	}

	public void indicateProcess(boolean b) {
		progressBar.setIndeterminate(b);
	}
	
}
